﻿using UnityEngine;

public class ElementCtrl {
	// === Public =====================================================================================================
	public Element ElementModel { get; private set; }
	public GameObject ElementView { get; private set; }

	public ElementCtrl(Element model, GameObject view) {
		ElementModel = model;
		ElementView = view;
	}

	public void SetPosition(Vector3 pos) {
		ElementModel.Position = pos;
		ElementView.transform.position = pos;
	}

	public void SetTexture(string texturePath) {
		if (ElementModel.TexturePath.Equals(texturePath)) {
			return;
		}
		ElementModel.TexturePath = texturePath;
		ElementView.renderer.material.mainTexture = Tools.Resources.GetObjectFromResources<Texture>(texturePath);
	}

	public void SetTexture(Texture texture) {
		if (ElementView.renderer.material.mainTexture.Equals(texture)) {
			return;
		}
		ElementModel.TexturePath = Tools.Resources.GetTexturePath(texture);
		ElementView.renderer.material.mainTexture = texture;
	}
}